package com.fei.BYSJ.service.impl;

import com.fei.BYSJ.dao.UserMapper;
import com.fei.BYSJ.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class UserServiceImpl implements com.fei.BYSJ.service.UserService {

    @Autowired
    UserMapper userMapper;

    @Override
    public int add(User userInfo) {
        return userMapper.insert(userInfo);
    }

    @Override
    public User findOne(int id) {
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<User> findAll(Map<String,Object> params) {
        return userMapper.findAll(params);
    }

    @Override
    public List<User> findByLogin(String userAccount,String userPassword) {
        return userMapper.findByLogin(userAccount,userPassword);
    }

    @Override
    public User findByAccount(String userAccount) {
        return userMapper.findByAccount(userAccount);
    }

    @Override
    public int uploadUser(User user) {
        return userMapper.updateByPrimaryKey(user);
    }

    @Override
    public int deleteUserById(int id) {
        return userMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int managerUploadUser(User user) {
        return userMapper.updateByPrimaryKeySelective(user);
    }
}
